package com.example.leetdemo.finash;

public class Solution504 {

    public String convertToBase7(int num) {
        StringBuilder builder = new StringBuilder();
        int temp = Math.abs(num);
        if (num == 0) {
            return "0";
        }
        while (temp != 0) {
            builder.append(temp % 7);
            temp = temp / 7;
        }
        if (num < 0) {
            builder.append("-");
        }
        return builder.reverse().toString();
    }

    public static void main(String[] args) {
        Solution504 solution504 = new Solution504();
        System.err.println(solution504.convertToBase7(0));
    }

}
